# -*- coding: utf-8 -*-
from gushici import db

class Author(db.Model):
    # Columns
    __tableName__ = 'author'
    _id = db.Column(db.INT, primary_key=True, autoincrement=True)
    id = db.Column(db.INT)
    likes = db.Column(db.INT)
    pic = db.Column(db.VARCHAR(20))
    idnew = db.Column(db.VARCHAR(50))
    nameStr = db.Column(db.VARCHAR(50))
    chaodai = db.Column(db.VARCHAR(20))
    creTime = db.Column(db.VARCHAR(50))
    shiCount = db.Column(db.INT)
    cont = db.Column(db.TEXT)
    ipStr = db.Column(db.VARCHAR(20))

    def __init__(self):
        return

    def __repr__(self):
        return '<Author %s>' % self.nameStr

    def __str__(self):
        return '<Author %s>' % self.nameStr

    def getResponseModel(self):
        return {
                'name': self.nameStr,
                'id': self.id,
                'authorid': self.idnew,
                'chaodai': self.chaodai,
                'count': self.shiCount,
                'intro': self.cont
            }


class AuthorZiliao(db.Model):
    # Columns
    __tableName__ = 'author_ziliao'
    _id = db.Column(db.INT, primary_key=True, autoincrement=True)
    id = db.Column(db.INT)
    nameStr = db.Column(db.VARCHAR(50))
    author = db.Column(db.VARCHAR(50))
    authorID = db.Column(db.INT)
    ok = db.Column(db.INT)
    noOk = db.Column(db.INT)
    cont = db.Column(db.TEXT)
    isPass = db.Column(db.SMALLINT)
    ipStr = db.Column(db.VARCHAR('20'))
    creTime = db.Column(db.VARCHAR('50'))
    cankao = db.Column(db.TEXT)
    isYuanchuang = db.Column(db.SMALLINT)

    def __init__(self):
        return

    def __repr__(self):
        return '<AuthZiliao %s : %s>' % (self.author, self.nameStr)

    def __str__(self):
        return '<AuthZiliao %s : %s>' % (self.author, self.nameStr)

    def getResponseModel(self):
        return {
            'title': self.nameStr,
            'author': self.author,
            'ok': self.ok,
            'noOk': self.noOk,
            'cont': self.cont,
            'cankao': self.cankao
        }


class Gushiwen(db.Model):
    # Columns
    __tableName__ = 'gushiwen'
    _id = db.Column(db.INT, primary_key=True, autoincrement=True)
    id = db.Column(db.INT)
    idnew = db.Column(db.VARCHAR(50))
    nameStr = db.Column(db.VARCHAR(50))
    author = db.Column(db.VARCHAR(50))
    chaodai = db.Column(db.VARCHAR(50))
    cont = db.Column(db.TEXT)
    axing = db.Column(db.INT)
    bxing = db.Column(db.INT)
    cxing = db.Column(db.INT)
    dxing = db.Column(db.INT)
    exing = db.Column(db.INT)
    tag = db.Column(db.VARCHAR(100))
    type = db.Column(db.VARCHAR(20))
    langsongAuthor = db.Column(db.VARCHAR(50))
    langsongAuthorPY = db.Column(db.VARCHAR(50))
    yizhuAuthor = db.Column(db.VARCHAR(50))
    yizhuCankao = db.Column(db.TEXT)
    yizhuYuanchuang = db.Column(db.SMALLINT)
    yizhuIspass = db.Column(db.SMALLINT)
    shangIspass = db.Column(db.SMALLINT)
    beijingIspass = db.Column(db.SMALLINT)
    pinglunCount = db.Column(db.INT)

    def __init__(self):
        return

    def __repr__(self):
        return '<Gushiwen %s : %s>' % (self.author, self.nameStr)

    def __str__(self):
        return '<Gushiwen %s : %s>' % (self.author, self.nameStr)

    def getResponseModel(self):
        return {
            'id': self.id,
            'idnew': self.idnew,
            'name': self.nameStr,
            'ok': self.exing,
            'cont': self.cont,
            'author': self.author,
            'chaodai': self.chaodai,
            'langsongAuthor': self.langsongAuthor,
            'langsongAuthorPY': self.langsongAuthorPY,
            'yizhuAuthor': self.yizhuAuthor,
            'yizhuCankao': self.yizhuCankao
        }